package unittest.demo;

import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException;
import dbutils.DbUtils;
import exttable.SGTTestParametrs;
import exttable.testselector.QueryHandler;
import exttable.timetable.ETestType;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * Created by IntelliJ IDEA.
 * User: alex
 * Date: 11/28/11
 * Time: 10:37 PM
 * To change this template use File | Settings | File Templates.
 */
public class ViewTest {

    @Before
    public void setInitialValue() throws Exception {
        SGTTestParametrs.getInstance().setServerAddress("localhost");
        DbUtils.GENERAL_DATABASE_NAME = "fs1";
    }

    @Test
    public void TestPhasesList() throws Exception {
        Assert.assertTrue(QueryHandler.getPhasesList(ETestType.OBJECT_DATA.name()) != null);
        Assert.assertTrue(QueryHandler.getPhasesList(ETestType.OBJECT_DATA.name()).size() > 0);
        Assert.assertNotNull(QueryHandler.getPhasesList(ETestType.OBJECT_DATA.name()));
    }

    @Test(expected = MySQLSyntaxErrorException.class)
    public void testException() throws Exception {
        DbUtils.GENERAL_DATABASE_NAME = "sa";
        Assert.assertTrue(QueryHandler.getPhasesList(ETestType.OBJECT_DATA.name()) != null);
    }
}
